﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CallBox.Entity;
using CallBox.BL;
using System.Web.Script.Serialization;
using System.Web.Services;

namespace CallBox.Private.Home
{
    public partial class _default : System.Web.UI.Page
    {
        
           
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                FillData();

            }

        }

        public void FillData()
        {
            try
            {
                
                if (Request.QueryString["ex"] != null)
                {
                    Int32 sType = Convert.ToInt32(Request.QueryString["ex"]);
                    List<clsMessage> lst = new List<clsMessage>();
                    if (sType > 0)
                    {
                        lst = clsMessageBL.Intancia.GetbyContact(sType);
                    }
                    else {
                        lst = clsMessageBL.Intancia.GetbyPapelera();
                    }
                    if (lst != null)
                    {
                        JavaScriptSerializer serializer = new JavaScriptSerializer();
                        string sJSON = serializer.Serialize(lst);
                        lblData.Value = sJSON.ToString();
                        if (lst.Count>0)
                            lblName.Text = lst[0].Mobile.FirtsName + "(" + lst[0].Mobile.Number+ ")";
                    }
                }
            }
            catch (Exception)
            {
            }
            

        }
        [WebMethod]
        public static Boolean delete(String Id)
        {
            Boolean IsCorrect = false;
            try
            {
                
                IsCorrect = clsMessageBL.Intancia.Update(Convert.ToInt32(Id), 2);


            }
            catch (Exception)
            {
                IsCorrect = false;
            }

            return IsCorrect;
        }
        [WebMethod]
        public static Boolean delete2(String Id)
        {
            Boolean IsCorrect = false;
            try
            {

                IsCorrect = clsMessageBL.Intancia.Update(Convert.ToInt32(Id), 3);


            }
            catch (Exception)
            {
                IsCorrect = false;
            }

            return IsCorrect;
        }
    }
}